package com.noble.glamour.ui.user.paygoods;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;

import com.noble.meether.R;
import com.noble.library.view.base.BasePanel;

/**
 * 支付方式通用panel
 * <p>
 * Created by Su on 2017/5/4.
 */
public class GoodsPayTypePanel extends BasePanel implements View.OnClickListener {
    private int payType = GoodsConstant.PAY_TYPE_WECHAT;  // 充值类型，默认微信充值
    private LinearLayout pay_wx, pay_alipay;

    public GoodsPayTypePanel(Context context) {
        super(context);
        setContentView(R.layout.p1_goods_of_payment);
        initView();
    }

    private void initView() {
        pay_wx = (LinearLayout) findViewById(R.id.pay_wx);
        pay_alipay = (LinearLayout) findViewById(R.id.pay_alipay);
        pay_wx.setOnClickListener(this);
        pay_alipay.setOnClickListener(this);
        pay_wx.setSelected(true);
    }

    /**
     * 获取支付类型
     */
    public int getPayType() {
        return payType;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.pay_wx:
                payType = GoodsConstant.PAY_TYPE_WECHAT;
                pay_wx.setSelected(true);
                pay_alipay.setSelected(false);
                break;

            case R.id.pay_alipay:
                payType = GoodsConstant.PAY_TYPE_ALIPAY;
                pay_wx.setSelected(false);
                pay_alipay.setSelected(true);
                break;
        }
    }
}
